package com.geen.tuoke.ui.dialog

import android.content.Context
import androidx.databinding.DataBindingUtil
import com.blankj.utilcode.util.LogUtils
import com.geen.tuoke.R
import com.geen.tuoke.bean.TaskDetailInfo
import com.geen.tuoke.bean.request.UpdateTaskMobile
import com.geen.tuoke.databinding.DialogTaskPhoneDetailBinding
import com.geen.tuoke.databinding.DialogTaskPhoneEditBinding
import com.geen.tuoke.utils.ext.dp2px
import com.geen.tuoke.widget.dialog.DialogViewHolder
import com.geen.tuoke.widget.dialog.XXDialog
import com.qmuiteam.qmui.kotlin.onClick

/**
 * @Desc 号码信息修改
 */
class DialogTaskPhoneEdit(
    context: Context,
    private var info: TaskDetailInfo,
    private var onConfirm: (updateRequest:UpdateTaskMobile ) -> Unit
) : XXDialog(context, R.layout.dialog_task_phone_edit) {

    private var mBinding: DialogTaskPhoneEditBinding? = null
    private lateinit var updateRequest: UpdateTaskMobile

    init {
        setWidthAndHeight(dp2px(288f), 0)
        setCanceledOnTouchOutside(false)
        updateRequest = UpdateTaskMobile()
        mBinding?.run {

            data = info
            LogUtils.json(info)

            ivClose.onClick {
                dismiss()
            }
            tvConfirm.onClick {
                updateRequest.company = etCompany.text.toString()
                updateRequest.mobile = etMobile.text.toString()
                updateRequest.name = etName.text.toString()
                updateRequest.remark = etRemark.text.toString()
                onConfirm(updateRequest)
                dismiss()
            }

        }
    }


    override fun convert(holder: DialogViewHolder) {
        mBinding = DataBindingUtil.bind(holder.convertView)
    }


}